package com.zcl.IO.Internet;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Description:
 * @author: zcl
 * @date: 2022/3/15  17:19
 */
public class InetAddressTest {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress inet1 = InetAddress.getByName("www.baidu.com");
        System.out.println(inet1);
        InetAddress inet2 = InetAddress.getLocalHost();
        System.out.println(inet2);
        String hostAddress = inet1.getHostAddress();
        System.out.println(hostAddress);
        String hostName = inet2.getHostName();
        System.out.println(hostName);

    }
}
